﻿
namespace UsingNonMVVMElements.Converter
{
    using System;
    using System.Windows.Data;

    public class UriConverter : IValueConverter
    {   
        public object Convert(object value, 
            System.Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {            
            //throw new NotImplementedException();
            return value;
        }       

        public object ConvertBack(object value, 
            System.Type targetType, object parameter, 
            System.Globalization.CultureInfo culture)
        {            
            string uri;
            if (value == null || 
                value.ToString().Trim() == string.Empty)
            {
                uri = "http://www.microsoft.com";
            }
            else
            {
                uri = value.ToString();
            }

            return new Uri(uri);
        }
    }
}
